import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mwm/base/base.dart';
import 'package:flutter_mwm/ui/city.dart';
import 'package:flutter_mwm/ui/weather.dart';
import 'package:flutter_mwm/widget/button.dart';
import 'package:flutter_mwm/widget/widget.dart';

void main() {
  runApp(MwMApp());
  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MwMApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MwM',
      home: TestHome(),
    );
  }
}

class TestHome extends BaseWidget<TestHome> {
  TestHome();

  @override
  State<StatefulWidget> createState() {
    return _StateTest();
  }
}

class _StateTest extends StateBase<TestHome> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0xFF051728),
        centerTitle: true,
        title: Text('测试'),
      ),
      body: ListView(
        children: _testWidget(),
      ),
    );
  }

  _testWidget() {
    List<Widget> _widgets = List();
    _widgets.add(_itemWidget(
        '天气',
        () => Navigator.push(
            context, MaterialPageRoute(builder: (_) => CityHome()))));
    return _widgets;
  }

  _itemWidget(String data, VoidCallback callback) {
    return ButtonText(
      '$data',
      onPressed: callback,
    );
  }
}
